home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
utility
/
252
/
dskpcsrc
/
clock.mod
< prev
next >
Wrap
Text File
|
1988-02-13
|
26KB
|
820 lines
IMPLEMENTATION MODULE Clock;
(*$S-,$T- turn off stack and range checking *)
FROM SYSTEM IMPORT ADR, ADDRESS;
IMPORT M2Conversions;
IMPORT GEMDOS;
IMPORT GEMVDIbase;
IMPORT VDIAttribs;
IMPORT VDIControls;
IMPORT VDIOutputs;
IMPORT GEMAESbase;
IMPORT AESEvents;
IMPORT AESWindows;
IMPORT AESApplications;
IMPORT AESObjects;
IMPORT AESForms;
IMPORT AESGraphics;
IMPORT Configuration;
IMPORT Text;
IMPORT TimeDate;
IMPORT Resource;
IMPORT Screen;
IMPORT Icon;
IMPORT Dialog;
IMPORT Window;
CONST
TimeErrorMsg = "[3][ An invalid time was entered. | The correct format is HH:MM.][ OK ]";
DateErrorMsg = "[3][ An invalid date was entered. | The correct format is DD/MM/YY.][ OK ]";
Bell = 07C;
TYPE
MsgBufferType = ARRAY [0..7] OF INTEGER;
String4 = ARRAY [0..4] OF CHAR;
String4Ptr = POINTER TO String4;
String6 = ARRAY [0..6] OF CHAR;
String6Ptr = POINTER TO String6;
String9 = ARRAY [0..9] OF CHAR;
String9Ptr = POINTER TO String9;
VAR
WindowAllocated : BOOLEAN;
WindowInfo : Window.Information;
Time : CARDINAL;
Date : CARDINAL;
DisplayedTime : String9;
DisplayedDate : String9;
SmallClock : BOOLEAN;
AlarmTime : CARDINAL;
AlarmOn : BOOLEAN;
SoundAlarm : BOOLEAN;
BellCount : CARDINAL;
Space : ARRAY[0..0] OF CHAR;
Corner : Screen.Box;
(************************** LOCAL ROUTINE ***************************)
PROCEDURE MinuteChanged;
VAR MsgBuffer : MsgBufferType;
BEGIN
MsgBuffer[0] := Resource.MinuteChanged;
MsgBuffer[1] := Resource.ApplicationId;
MsgBuffer[2] := 0;
MsgBuffer[3] := Time DIV 2048; (* Hours *)
MsgBuffer[4] := (Time MOD 2048) DIV 32; (* Minutes *)
MsgBuffer[5] := 0; (* Ignore the seconds *)
AESApplications.ApplWrite (
Resource.ApplicationId,
SIZE (MsgBuffer),
ADR (MsgBuffer) );
END MinuteChanged;
(************************** LOCAL ROUTINE ***************************)
PROCEDURE DateChanged;
VAR MsgBuffer : MsgBufferType;
BEGIN
MsgBuffer[0] := Resource.DateChanged;
MsgBuffer[1] := Resource.ApplicationId;
MsgBuffer[2] := 0;
MsgBuffer[3] := Date MOD 32; (* Day *)
MsgBuffer[4] := (Date MOD 512) DIV 32; (* Month *)
MsgBuffer[5] := (Date DIV 512) + 1980; (* Year *)
AESApplications.ApplWrite (
Resource.ApplicationId,
SIZE (MsgBuffer),
ADR (MsgBuffer) );
END DateChanged;
(************************** LOCAL ROUTINE ***************************)
PROCEDURE SetAlarm;
CONST NoFormat = FALSE;
TYPE TedInfoPtrType = POINTER TO Icon.Tedinfo;
VAR
PMPtr : Icon.ObjectPtr;
AMPtr : Icon.ObjectPtr;
TimePtr : Icon.ObjectPtr;
TedinfoPtr : TedInfoPtrType;
TextPtr : String4Ptr;
PM : BOOLEAN;
AlarmOnPtr : Icon.ObjectPtr;
AlarmOffPtr : Icon.ObjectPtr;
ExitButton : INTEGER;
BEGIN
PMPtr := Icon.GetAddress ( Resource.D5SETALM, Resource.D5PM );
AMPtr := Icon.GetAddress ( Resource.D5SETALM, Resource.D5AM );
TimePtr := Icon.GetAddress ( Resource.D5SETALM, Resource.D5TIME );
TedinfoPtr := TedInfoPtrType (TimePtr^.Spec);
TextPtr := String4Ptr (TedinfoPtr^.Text);
LOOP
DecodeTime ( AlarmTime, NoFormat, TextPtr^ );
IF (AlarmTime DIV 2048) < 12 THEN
PMPtr^.State := PMPtr^.State - {Icon.Selected};
AMPtr^.State := AMPtr^.State + {Icon.Selected};
ELSE
PMPtr^.State := PMPtr^.State + {Icon.Selected};
AMPtr^.State := AMPtr^.State - {Icon.Selected};
END;
IF Dialog.Display (
Resource.D5SETALM,
Screen.Center,
Resource.D5TIME ) = Resource.D5OK THEN
PM := Icon.Selected IN PMPtr^.State;
IF EncodeTime ( TextPtr^, PM, AlarmTime ) THEN
AlarmOnPtr := Icon.GetAddress (
Resource.D2CLOCK, Resource.D2ALRMON );
AlarmOnPtr^.Flags := AlarmOnPtr^.Flags - {Icon.HideTree};
AlarmOffPtr := Icon.GetAddress (
Resource.D2CLOCK, Resource.D2ALRMOF );
AlarmOffPtr^.Flags := AlarmOffPtr^.Flags + {Icon.HideTree};
AlarmOn := TRUE;
IF WindowAllocated THEN
Window.Redraw ( WindowInfo.Id, WindowInfo.Borders );
END;
EXIT;
ELSE
ExitButton := AESForms.FormAlert ( 1, TimeErrorMsg );
END;
ELSE
EXIT;
END;
END;
END SetAlarm;
(************************** LOCAL ROUTINE ***************************)
PROCEDURE ClockDraw ( Region : Screen.Box );
(* Note: This procedure is invoked only when the clock *)
(* is full size. *)
CONST UseFormat = TRUE;
BEGIN
DecodeTime ( Time, UseFormat, DisplayedTime );
GEMDOS.GetDate ( Date );
DecodeDate ( Date, UseFormat, DisplayedDate );
Icon.Display ( Resource.D2CLOCK, 0, Region );
END ClockDraw;
(************************** LOCAL ROUTINE ***************************)
PROCEDURE SmallClockDraw ( ShowTime : BOOLEAN );
CONST
ClippingOn = 1;
Hollow = 0;
UseFormat = TRUE;
VAR
FillStyle : INTEGER;
PxyArray : GEMVDIbase.PxyArrayType;
BEGIN
FillStyle := VDIAttribs.SetFillInteriorStyle (
Screen.VirtualHandle, Hollow );
PxyArray[0] := Corner.Origin.X;
PxyArray[1] := Corner.Origin.Y;
PxyArray[2] := Corner.Origin.X + Corner.Size.Width - 1;
PxyArray[3] := Corner.Origin.Y + Corner.Size.Height - 1;
VDIControls.SetClipping (
Screen.VirtualHandle, ClippingOn, PxyArray );
VDIOutputs.FillRectangle ( Screen.VirtualHandle, PxyArray );
IF ShowTime THEN
DecodeTime ( Time, UseFormat, DisplayedTime );
VDIOutputs.GraphicText (
Screen.VirtualHandle,
Corner.Origin.X,
Corner.Origin.Y + Screen.CharacterArea.Height - 1,
DisplayedTime );
END;
END SmallClockDraw;
(************************** LOCAL ROUTINE ***************************)
PROCEDURE AlarmOff;
VAR ObjectPtr : Icon.ObjectPtr;
BEGIN
ObjectPtr := Icon.GetAddress ( Resource.D2CLOCK, Resource.D2ALRMON );
ObjectPtr^.Flags := ObjectPtr^.Flags + {Icon.HideTree};
ObjectPtr := Icon.GetAddress ( Resource.D2CLOCK, Resource.D2ALRMOF );
ObjectPtr^.Flags := ObjectPtr^.Flags - {Icon.HideTree};
AlarmOn := FALSE;
SoundAlarm := FALSE;
(* TimerResolution := 15000; 6/6/87 - SMN *)
TimerResolution := 5000; (* 5 seconds *) (* 6/6/87 - SMN *)
END AlarmOff;
(********************************************************************)
PROCEDURE Initialize;
VAR
TimePtr : Icon.ObjectPtr;
DatePtr : Icon.ObjectPtr;
BEGIN
Corner.Size.Width := Screen.CharacterArea.Width * 9;
Corner.Size.Height := Screen.CharacterArea.Height;
Corner.Origin.X := Screen.WorkSpace.Size.Width - Corner.Size.Width;
Corner.Origin.Y := 0;
TimePtr := Icon.GetAddress ( Resource.D2CLOCK, Resource.D2TIME );
TimePtr^.Spec := ADR ( DisplayedTime );
DatePtr := Icon.GetAddress ( Resource.D2CLOCK, Resource.D2DATE );
DatePtr^.Spec := ADR ( DisplayedDate );
(*---- Prompt the user to set the time and date -----------------*)
IF (Configuration.ShowTime[0] <> 'N') AND
(Configuration.ShowTime[0] <> 'n') THEN
AESEvents.EventTimer ( 3000,0 ); (* Allow time for windows to open *)
AESWindows.WindowUpdate ( GEMAESbase.BeginUpdate );
SetTime;
SetDate;
AESWindows.WindowUpdate ( GEMAESbase.EndUpdate );
ELSE
GEMDOS.SetDate ( TimeDate.GetDate () );
GEMDOS.SetTime ( TimeDate.GetTime () );
END;
END Initialize;
(********************************************************************)
PROCEDURE DayPeriod () : BOOLEAN;
VAR Hours : CARDINAL;
BEGIN
Hours := Time DIV 2048;
RETURN ((Hours >= 8) AND (Hours < 17));
END DayPeriod;
(********************************************************************)
PROCEDURE EveningPeriod () : BOOLEAN;
VAR Hours : CARDINAL;
BEGIN
Hours := Time DIV 2048;
RETURN ((Hours >= 17) AND (Hours < 23));
END EveningPeriod;
(********************************************************************)
PROCEDURE NightPeriod () : BOOLEAN;
VAR Hours : CARDINAL;
BEGIN
Hours := Time DIV 2048;
RETURN ((Hours >= 23) OR (Hours < 8));
END NightPeriod;
(********************************************************************)
PROCEDURE DecodeTime ( Time : CARDINAL;
UseFormat : BOOLEAN;
VAR FormattedTime : ARRAY OF CHAR );
VAR
PM : BOOLEAN;
Hours : CARDINAL;
Minutes : CARDINAL;
Buffer : String9;
Success : BOOLEAN;
BEGIN
Hours := Time DIV 2048;
IF Hours > 23 THEN
FormattedTime[0] := CHR (0);
ELSE
Minutes := (Time MOD 2048) DIV 32;
IF Minutes > 59 THEN
FormattedTime[0] := CHR (0);
ELSE
IF Hours = 0 THEN
PM := FALSE;
Hours := 12;
ELSIF Hours < 12 THEN
PM := FALSE;
ELSE
PM := TRUE;
IF Hours > 12 THEN
Hours := Hours - 12;
END;
END;
M2Conversions.ConvertCardinal ( Hours, 2, FormattedTime );
IF UseFormat THEN
FormattedTime[2] := ':';
FormattedTime[3] := CHR (0);
END;
M2Conversions.ConvertCardinal ( Minutes, 2, Buffer );
IF Buffer[0] = ' ' THEN
Buffer[0] := '0';
END;
Success := Text.ConcatString (
FormattedTime, Buffer, FormattedTime );
IF UseFormat THEN
IF PM THEN
Success := Text.ConcatString (
FormattedTime, " PM ", FormattedTime );
ELSE
Success := Text.ConcatString (
FormattedTime, " AM ", FormattedTime );
END;
END;
END;
END;
END DecodeTime;
(********************************************************************)
PROCEDURE DecodeDate ( Date : CARDINAL;
UseFormat : BOOLEAN;
VAR FormattedDate : ARRAY OF CHAR );
VAR
Day : CARDINAL;
Month : CARDINAL;
Year : CARDINAL;
Buffer : String9;
Success : BOOLEAN;
BEGIN
Year := (Date DIV 512) + 80; (* Only adjust last two digits *)
IF Year > 99 THEN
Year := Year - 100;
END;
Month := (Date MOD 512) DIV 32;
Day := Date MOD 32;
M2Conversions.ConvertCardinal ( Month, 2, FormattedDate );
IF UseFormat THEN
FormattedDate[2] := '/';
FormattedDate[3] := CHR (0);
END;
M2Conversions.ConvertCardinal ( Day, 2, Buffer );
IF Buffer[0] = ' ' THEN
Buffer[0] := '0';
END;
Success := Text.ConcatString ( FormattedDate, Buffer, FormattedDate );
IF UseFormat THEN
FormattedDate[5] := '/';
FormattedDate[6] := CHR (0);
END;
M2Conversions.ConvertCardinal ( Year, 2, Buffer );
IF Buffer[0] = ' ' THEN
Buffer[0] := '0';
END;
Success := Text.ConcatString ( FormattedDate, Buffer, FormattedDate );
END DecodeDate;
(********************************************************************)
PROCEDURE EncodeTime ( VAR FormattedTime : ARRAY OF CHAR;
PM : BOOLEAN;
VAR Time : CARDINAL ) : BOOLEAN;
VAR
Hours : CARDINAL;
Minutes : CARDINAL;
Buffer : String9;
Success : BOOLEAN;
BEGIN
Success := Text.SliceString ( FormattedTime, 0, 1, Buffer );
M2Conversions.ConvertToCardinal ( Buffer, Success, Hours );
IF (NOT Success) OR (Hours < 1) OR (Hours > 12) THEN
Time := 0;
RETURN (FALSE);
END;
IF PM AND (Hours < 12) THEN
Hours := Hours + 12;
ELSIF (NOT PM) AND (Hours = 12) THEN
Hours := 0;
END;
Success := Text.SliceString ( FormattedTime, 2, 3, Buffer );
M2Conversions.ConvertToCardinal ( Buffer, Success, Minutes );
IF (NOT Success) OR (Minutes > 59) THEN
Time := 0;
RETURN (FALSE);
END;
Time := (Hours * 2048) + (Minutes * 32);
RETURN (TRUE);
END EncodeTime;
(********************************************************************)
PROCEDURE EncodeDate ( VAR FormattedDate : ARRAY OF CHAR;
VAR Date : CARDINAL ) : BOOLEAN;
VAR
Day : CARDINAL;
Month : CARDINAL;
Year : CARDINAL;
Buffer : String9;
Success : BOOLEAN;
BEGIN
Success := Text.SliceString ( FormattedDate, 0, 1, Buffer );
M2Conversions.ConvertToCardinal ( Buffer, Success, Month );
IF (NOT Success) OR (Month < 1) OR (Month > 12) THEN
Date := 0;
RETURN (FALSE);
END;
Success := Text.SliceString ( FormattedDate, 2, 3, Buffer );
M2Conversions.ConvertToCardinal ( Buffer, Success, Day );
IF (NOT Success) OR (Day < 1) OR (Day > 31) THEN
Date := 0;
RETURN (FALSE);
END;
Success := Text.SliceString ( FormattedDate, 4, 5, Buffer );
M2Conversions.ConvertToCardinal ( Buffer, Success, Year );
IF NOT Success THEN
Date := 0;
RETURN (FALSE);
END;
IF Year < 85 THEN (* Since only two digits are entered, *)
Year := Year + 100; (* adjust year if year is 0 to 84. *)
END;
Date := ((Year - 80) * 512) + (Month * 32) + Day;
RETURN (TRUE);
END EncodeDate;
(********************************************************************)
PROCEDURE SetTime;
CONST NoFormat = FALSE;
TYPE TedInfoPtrType = POINTER TO Icon.Tedinfo;
VAR
SystemTime : CARDINAL;
PMPtr : Icon.ObjectPtr;
AMPtr : Icon.ObjectPtr;
TimePtr : Icon.ObjectPtr;
TedinfoPtr : TedInfoPtrType;
TextPtr : String4Ptr;
PM : BOOLEAN;
ExitButton : INTEGER;
BEGIN
PMPtr := Icon.GetAddress ( Resource.D3SETTIM, Resource.D3PM );
AMPtr := Icon.GetAddress ( Resource.D3SETTIM, Resource.D3AM );
TimePtr := Icon.GetAddress ( Resource.D3SETTIM, Resource.D3TIME );
TedinfoPtr := TedInfoPtrType (TimePtr^.Spec);
TextPtr := String4Ptr (TedinfoPtr^.Text);
LOOP
SystemTime := TimeDate.GetTime ();
DecodeTime ( SystemTime, NoFormat, TextPtr^ );
IF (SystemTime DIV 2048) < 12 THEN
PMPtr^.State := PMPtr^.State - {Icon.Selected};
AMPtr^.State := AMPtr^.State + {Icon.Selected};
ELSE
PMPtr^.State := PMPtr^.State + {Icon.Selected};
AMPtr^.State := AMPtr^.State - {Icon.Selected};
END;
IF Dialog.Display (
Resource.D3SETTIM,
Screen.Center,
Resource.D3TIME ) = Resource.D3OK THEN
PM := Icon.Selected IN PMPtr^.State;
IF EncodeTime ( TextPtr^, PM, Time ) THEN
GEMDOS.SetTime ( Time );
MinuteChanged;
IF WindowAllocated THEN
Window.Redraw ( WindowInfo.Id, WindowInfo.Borders );
END;
EXIT;
ELSE
ExitButton := AESForms.FormAlert ( 1, TimeErrorMsg );
END;
ELSE
EXIT;
END;
END (* LOOP *);
END SetTime;
(********************************************************************)
PROCEDURE SetDate;
CONST NoFormat = FALSE;
TYPE TedInfoPtrType = POINTER TO Icon.Tedinfo;
VAR
SystemDate : CARDINAL;
DatePtr : Icon.ObjectPtr;
TedinfoPtr : TedInfoPtrType;
TextPtr : String6Ptr;
ExitButton : INTEGER;
BEGIN
DatePtr := Icon.GetAddress ( Resource.D4SETDAT, Resource.D4DATE );
TedinfoPtr := TedInfoPtrType (DatePtr^.Spec);
TextPtr := String6Ptr (TedinfoPtr^.Text);
LOOP
SystemDate := TimeDate.GetDate ();
DecodeDate ( SystemDate, NoFormat, TextPtr^ );
IF Dialog.Display (
Resource.D4SETDAT,
Screen.Center,
Resource.D4DATE ) = Resource.D4OK THEN
IF EncodeDate ( TextPtr^, Date ) THEN
GEMDOS.SetDate ( Date );
DateChanged;
IF WindowAllocated THEN
Window.Redraw ( WindowInfo.Id, WindowInfo.Borders );
END;
EXIT;
ELSE
ExitButton := AESForms.FormAlert ( 1, DateErrorMsg );
END;
ELSE
EXIT;
END;
END (* LOOP *);
END SetDate;
(********************************************************************)
PROCEDURE OwnsWindow ( WindowId : INTEGER ) : BOOLEAN;
BEGIN
IF WindowAllocated THEN
RETURN (WindowId = WindowInfo.Id);
ELSE
RETURN (FALSE);
END;
END OwnsWindow;
(********************************************************************)
PROCEDURE Open;
CONST EraseTime = FALSE;
VAR
WindowRegion : Screen.Box;
WindowName : Text.String80;
VirtualRegionSize : Window.Area;
BEGIN
IF WindowAllocated THEN
Window.Top ( WindowInfo.Id );
ELSE
Icon.GetRegion ( Resource.D2CLOCK, 0, WindowRegion );
WindowRegion.Origin.X :=
Screen.Center.Origin.X - (WindowRegion.Size.Width DIV 2);
WindowRegion.Origin.Y :=
Screen.Center.Origin.Y - (WindowRegion.Size.Height DIV 2);
VirtualRegionSize.Width :=
Window.Pixel (WindowRegion.Size.Width);
VirtualRegionSize.Height :=
Window.Pixel (WindowRegion.Size.Height);
IF SmallClock THEN
SmallClockDraw ( EraseTime );
AESGraphics.GrafGrowBox (
Corner.Origin.X,
Corner.Origin.Y,
Corner.Size.Width,
Corner.Size.Height,
WindowRegion.Origin.X,
WindowRegion.Origin.Y,
WindowRegion.Size.Width,
WindowRegion.Size.Height );
SmallClock := FALSE;
END;
IF Window.Open (
Screen.Center,
Window.InformationPtr (ADR (WindowInfo)),
" Clock ",
"", (* No information line *)
WindowRegion,
VirtualRegionSize,
GEMAESbase.Name +
GEMAESbase.Closer +
GEMAESbase.Fuller +
GEMAESbase.Mover,
0, 1, (* White Background *)
Resource.D2CLOCK,
ClockDraw ) THEN
WindowAllocated := TRUE;
ELSE
Window.Unavailable;
WindowAllocated := FALSE;
END;
END;
END Open;
(********************************************************************)
PROCEDURE Close;
BEGIN
IF SoundAlarm THEN
AlarmOff;
END;
IF WindowAllocated THEN
Window.Close ( WindowInfo.Id, Screen.Center );
WindowAllocated := FALSE;
END;
END Close;
(********************************************************************)
PROCEDURE ProcessTimerEvent;
CONST ShowTime = TRUE;
VAR SystemTime : CARDINAL;
BEGIN
IF AlarmOn AND SoundAlarm THEN
GEMDOS.ConOut ( Bell );
IF BellCount > 0 THEN
DEC ( BellCount );
END;
END;
GEMDOS.GetTime ( SystemTime );
SystemTime := SystemTime DIV 32 * 32; (* Get rid of seconds *)
IF SystemTime <> Time THEN
IF SystemTime < Time THEN
GEMDOS.GetDate ( Date );
DateChanged;
END;
Time := SystemTime;
MinuteChanged;
IF AlarmOn AND (Time >= AlarmTime) AND (NOT SoundAlarm) THEN
Open (); (* Either open a clock window or top it *)
SoundAlarm := TRUE;
BellCount := 3;
TimerResolution := 1000; (* 1 seconds *)
ELSIF SmallClock THEN
SmallClockDraw ( ShowTime );
ELSIF WindowAllocated THEN
Window.Redraw ( WindowInfo.Id, WindowInfo.Borders );
END;
END;
END ProcessTimerEvent;
(********************************************************************)
PROCEDURE ProcessMessageEvent ( VAR MsgBuffer : ARRAY OF INTEGER );
CONST ShowTime = TRUE;
VAR WindowRegion : Screen.Box;
BEGIN
IF MsgBuffer[0] = GEMAESbase.AccessoryClose THEN
IF SmallClock THEN
SmallClockDraw ( ShowTime );
ELSIF WindowAllocated THEN
Window.Close ( 0, Screen.Center );
WindowAllocated := FALSE;
END;
ELSIF MsgBuffer[0] = GEMAESbase.WindowFulled THEN
IF SoundAlarm AND (BellCount = 0) THEN
AlarmOff;
END;
WindowRegion := WindowInfo.Borders;
Close ();
AESGraphics.GrafShrinkBox (
Corner.Origin.X,
Corner.Origin.Y,
Corner.Size.Width,
Corner.Size.Height,
WindowRegion.Origin.X,
WindowRegion.Origin.Y,
WindowRegion.Size.Width,
WindowRegion.Size.Height );
SmallClockDraw ( ShowTime );
SmallClock := TRUE;
ELSE
IF SoundAlarm AND (BellCount = 0) THEN
AlarmOff;
Icon.Display ( Resource.D2CLOCK, Resource.D2ALRMOF, WindowInfo.Borders );
END;
GEMDOS.ConOut ( Bell );
END;
END ProcessMessageEvent;
(********************************************************************)
PROCEDURE ProcessButtonEvent ( MouseButton : INTEGER;
ModifierKey : INTEGER;
Clicks : INTEGER );
VAR
MouseLocation : Screen.PixelCoordinate;
MouseState : INTEGER;
KeyboardState : INTEGER;
Object : INTEGER;
ObjectPtr : Icon.ObjectPtr;
BEGIN
IF SoundAlarm AND (BellCount = 0) THEN
AlarmOff;
Icon.Display ( Resource.D2CLOCK, Resource.D2ALRMOF, WindowInfo.Borders );
END;
AESGraphics.GrafMouseKeyboardState (
MouseLocation.X,
MouseLocation.Y,
MouseState,
KeyboardState );
IF Icon.Find ( Resource.D2CLOCK, MouseLocation, Object ) THEN
IF Object = Resource.D2TIME THEN
IF Clicks = 2 THEN
SetTime;
END;
ELSIF Object = Resource.D2DATE THEN
IF Clicks = 2 THEN
SetDate;
END;
ELSIF Object = Resource.D2ALRMON THEN
IF Clicks = 1 THEN
AlarmOff;
Icon.Display (
Resource.D2CLOCK,
Resource.D2ALRMOF,
WindowInfo.Borders );
ELSE
SetAlarm ();
END;
ELSIF Object = Resource.D2ALRMOF THEN
IF Clicks = 1 THEN
ObjectPtr := Icon.GetAddress (
Resource.D2CLOCK, Resource.D2ALRMON );
ObjectPtr^.Flags := ObjectPtr^.Flags - {Icon.HideTree};
ObjectPtr := Icon.GetAddress (
Resource.D2CLOCK, Resource.D2ALRMOF );
ObjectPtr^.Flags := ObjectPtr^.Flags + {Icon.HideTree};
AlarmOn := TRUE;
Icon.Display (
Resource.D2CLOCK,
Resource.D2ALRMON,
WindowInfo.Borders );
ELSE
SetAlarm ();
END;
ELSE
GEMDOS.ConOut ( Bell );
END;
END;
END ProcessButtonEvent;
(********************************************************************)
PROCEDURE ProcessKeyboardEvent ( Key : INTEGER;
ModifierKey : INTEGER );
BEGIN
IF SoundAlarm AND (BellCount = 0) THEN
AlarmOff;
Icon.Display ( Resource.D2CLOCK, Resource.D2ALRMOF, WindowInfo.Borders );
END;
GEMDOS.ConOut ( Bell );
END ProcessKeyboardEvent;
BEGIN
(* TimerResolution := 15000; 6/6/87 - SMN *)
TimerResolution := 5000; (* 5 seconds *) (* 6/6/87 - SMN *)
WindowAllocated := FALSE;
Time := 0;
Date := 0;
DisplayedTime := "";
DisplayedDate := "";
SmallClock := FALSE;
AlarmTime := 0;
AlarmOn := FALSE;
SoundAlarm := FALSE;
Space := " ";
END Clock.